package com.xiaozeng.cart.controller;

import com.xiaozeng.cart.service.CartService;
import com.xiaozeng.param.CartParam;
import com.xiaozeng.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: xiaozeng
 * @Date: 2022 11
 * @Description:
 **/

@RequestMapping("cart")
@RestController
public class CartController {
    @Autowired
    private CartService cartService;

    /**
     * 添加购物车
     */
    @PostMapping("save")
    public Result save(@RequestBody CartParam cartParam){

        return cartService.save(cartParam);
    }

    /**
     * 查看购物车
     */
    @PostMapping("list")
    public Result list(){

        return cartService.cartList();
    }
    /**
     * 删除购物车
     */
    @PostMapping("remove")
    public Result remove(@RequestBody CartParam cartParam){

        return cartService.remove(cartParam);
    }
}
